package com.xjt.query.dao.impl;

import java.util.List;

import org.apache.commons.collections.CollectionUtils;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.xjt.query.dao.interf.CommonCompanyInfoDao;
import com.xjt.query.dao.pojo.BaseCompanyInfo;
import com.xjt.query.entity.LeadsQueryVo;

public class CommonCompanyInfoDaoImpl extends SqlMapClientDaoSupport implements CommonCompanyInfoDao {

    public int countCompanyInfo(LeadsQueryVo query) {
        Integer count = (Integer) getSqlMapClientTemplate().queryForObject("common_company_info.countCompanyInfo", query);
        return count;
    }

    @SuppressWarnings("unchecked")
    public List<BaseCompanyInfo> queryCompanyInfoPaging(LeadsQueryVo query) {
        List<BaseCompanyInfo> list = getSqlMapClientTemplate().queryForList("common_company_info.queryCompanyInfoPaging",
                                                                          query);
        return list;
    }

    @Override
    public BaseCompanyInfo selectCompanyInfoById(LeadsQueryVo query) {
        List<BaseCompanyInfo> list = queryCompanyInfoPaging(query);
        if (CollectionUtils.isNotEmpty(list)) {
            return list.get(0);
        }
        return null;
    }
}
